<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <script src="./js/ajax.js" type="text/javascript" charset="utf-8"></script>
    <title>Document</title>
    <style>
      .addInput div {
        margin-top: 30px;
      }

      .title {
        -webkit-appearance: none;
        background-color: #fff;
        background-image: none;
        border-radius: 4px;
        border: 1px solid #dcdfe6;
        box-sizing: border-box;
        color: #606266;
        display: inline-block;
        font-size: inherit;
        height: 40px;
        line-height: 40px;
        outline: none;
        padding: 0 15px;
      }

      .content {
        display: block;
        resize: vertical;
        padding: 5px 15px;
        line-height: 1.5;
        box-sizing: border-box;
        width: 300px;
        height: 100px;
        font-size: inherit;
        color: #606266;
        background-color: #fff;
        background-image: none;
        border: 1px solid #dcdfe6;
        border-radius: 4px;
      }

      .addInput div input:focus {
        outline: none;
        border-color: #409eff;
      }

      .contentContainer {
        display: flex;
      }

      .selectStyle {
        background-color: #fff;
        background-image: none;
        border-radius: 4px;
        border: 1px solid #dcdfe6;
        box-sizing: border-box;
        color: #606266;
        display: inline-block;
        font-size: inherit;
        height: 40px;
        line-height: 40px;
        outline: none;
        padding: 0 15px;
        width: 200px;
      }

      .fileinput-button {
        position: relative;
        display: inline-block;
        overflow: hidden;
        background: #409eff;
        padding: 9px 15px;
        font-size: 12px;
        border-radius: 3px;
        color: white;
      }

      .fileinput-button input {
        position: absolute;
        right: 0px;
        top: 0px;
        opacity: 0;
        font-size: 50px;
      }

      .btn {
        background-color: #409eff;
        color: white;
        display: inline-block;
        line-height: 1;
        white-space: nowrap;
        cursor: pointer;
        border: 1px solid #dcdfe6;
        -webkit-appearance: none;
        text-align: center;
        box-sizing: border-box;
        outline: none;
        margin: 0;
        transition: 0.1s;
        font-weight: 500;
        padding: 12px 20px;
        font-size: 14px;
        border-radius: 4px;
      }
    </style>
  </head>

  <body>
    <div class="menu-content">
      <h1>添加新闻</h1>
      <form
        class="addInput"
        method="post"
        enctype="multipart/form-data"
        onsubmit="return false;"
      >
        <div>
          <!-- mvc module view controller -->
          标题：<input class="title" name="title" type="text" />
        </div>
        <div class="contentContainer">
          内容：<textarea
            class="content"
            name="content"
            id=""
            cols="30"
            rows="10"
          ></textarea>
        </div>
        <div>
          类型：<select class="selectStyle" name="type" id="">
            <option value="逮捕">逮捕</option>
            <option value="消息">消息</option>
            <option value="通讯">通讯</option>
            <option value="文学">文学</option>
          </select>
        </div>
        <div>
          国家：<select class="selectStyle" name="country" id="">
            <option value="美国">美国</option>
            <option value="韩国">韩国</option>
            <option value="日本">日本</option>
            <option value="英国">英国</option>
          </select>
        </div>
        <div class="uploadContainer">
          缩略图：
          <span class="fileinput-button">
            <span>上传图片</span>
            <input class="imgFile" type="file" name="myimg" />
          </span>
        </div>
        <div>
          <button class="btn" type="submit">提交</button>
        </div>
      </form>
    </div>
    <script src="./js/addnews.js">
         // let btn = document.querySelector(".btn"); // btn.onclick = function () {
      // let content = document.querySelector(".content").value; // let title =
      // document.querySelector(".title").value; // let imgfile =
      // document.querySelector(".imgFile").files[0]; // // let type =
      // document.querySelector(".selectStyle").value; // // let country =
      // document.querySelector(".country").value; // let form = new FormData(); //
      // form.append("content", content); // form.append("title", title); //
      // form.append("img", imgfile); // let xhr = new XMLHttpRequest(); //
      // xhr.open("POST", "addnews.php"); // xhr.onload = function () { //
      // console.log(xhr.responseText); // window.location.href = "index.html"; // };
      // xhr.send(form); // e.preventdefault(); // };
    </script>
  </body>
</html>
